home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Skunkware 5
/
Skunkware 5.iso
/
src
/
X11
/
endo
/
vueinit.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-05-03
|
4KB
|
102 lines
/*************************************************************************
* *
* Copyright (c) 1992, 1993 Ronald Joe Record *
* *
* All rights reserved. No part of this program or publication may be *
* reproduced, transmitted, transcribed, stored in a retrieval system, *
* or translated into any language or computer language, in any form or *
* by any means, electronic, mechanical, magnetic, optical, chemical, *
* biological, or otherwise, without the prior written permission of: *
* *
* Ronald Joe Record (408) 458-3718 *
* 212 Owen St., Santa Cruz, California 95062 USA *
* *
*************************************************************************/
/*************************************************************************
* *
* Copyright (c) 1989 Hiram Clawson *
* *
* All rights reserved. No part of this program or publication may be *
* reproduced, transmitted, transcribed, stored in a retrieval system, *
* or translated into any language or computer language, in any form or *
* by any means, electronic, mechanical, magnetic, optical, chemical, *
* biological, or otherwise, without the prior written permission of: *
* *
* Hiram Clawson (408) 429-5647 *
* P. O. Box 3178, Santa Cruz, California 95063-3178 USA *
* *
*************************************************************************/
/*************************************************************************
* vueinit.c: Initialize the 3D viewing window *
* *
* Written by Hiram Clawson. *
* Ported to X11 by Ronald Joe Record. *
*************************************************************************/
#define __MAIN__
#include "globals.h"
#undef __MAIN__
void
vue_init( wc, win_wide, win_high )
triple wc;
int win_wide, win_high;
{
static double length_center_upper_right;
static double window_half_height;
extern void view_point_constants();
screen_max.x = win_wide;
screen_max.y = win_high;
screen_center.x = win_wide >> 1;
screen_center.y = win_high >> 1;
window_center.x = wc.x; window_center.y = wc.y; window_center.z = wc.z;
window_half_height = sqrt((wc.x * wc.x) +
(wc.y * wc.y) +
(wc.z * wc.z)) / 2.0;
/* establish initial viewing window in 3D space */
/* the initial window is parallel to the X-Y plane */
/* and window_origin_distance units from the origin */
/* NOTE: window units are whatever 3D space units are */
/* the top of the window is window_half_height units high on the Y axis */
window_top.x = wc.x;
window_top.y = wc.y + window_half_height;
window_top.z = wc.z;
window_right.x = window_top.y;
window_right.y = wc.y;
window_right.z = wc.z;
/* the window upper right is determined by the top and right sides */
window_upper_right.x = window_right.x;
window_upper_right.y = window_top.y;
window_upper_right.z = wc.z;
/* compute distance from center to upper right */
length_center_upper_right = sqrt(
((window_upper_right.x - wc.x)*(window_upper_right.x - wc.x)) +
((window_upper_right.z - wc.z)*(window_upper_right.z - wc.z)) +
((window_upper_right.y - wc.y)*(window_upper_right.y - wc.y)));
/* and the view point is further along the positive Z axis */
/* by an amount to make the angle (center - view - upper right) be */
/* 30 degrees so that the initial field of view will be 60 degrees */
view_point.x = window_center.x;
view_point.y = window_center.y;
view_point.z = window_center.z + (length_center_upper_right /
TAN_30_DEGREES);
view_point_constants();
return;
} /* end of view_init */